Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cnamts/cli-helpers

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cnamts/cli-helpers

Helper functions to build CLI tools

  • 2.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by28.57%
Maintainers
2
Weekly downloads
 
Created
Source

CLI Helpers

Helper functions to build CLI tools.

Installation

This package is built with TypeScript and is meant to be used in TypeScript projects, but a JavaScript version is built so you can use it in node.js environment.

To install it, you need to use yarn or npm:

yarn add @cnamts/cli-helpers
# OR
npm install @cnamts/cli-helpers

Usage

You can import the different helpers from the main file:

import { log, done, getPath } from '@cnamts/cli-helpers';

Or you can import them using their files, like so:

import { log, done } from '@cnamts/cli-helpers/src/logger';
import { getPath } from '@cnamts/cli-helpers/src/getPath';

Helpers

colors

Get an object with standardized colors.

import { colors } from '@cnamts/cli-helpers';

console.log(colors.primary); // Use 'primary' color

getPath

Get path relative to current working directory.

import { getPath } from '@cnamts/cli-helpers';

const myPath = getPath('./file'); // Equivalent to path.join(process.cwd(), './file)

traceLine

Trace a straight line across the terminal using box-drawing character , by default it uses the primary color from colors, but you can change it.

import { traceLine } from '@cnamts/cli-helpers';

traceLine(); // Example: ───────────────────────

traceLine('#eee') // With custom color

logger

Log informations to the user such as errors, warnings, events and others.

import { log, cmd, info, done, warn, error, verbose, event } from '@cnamts/cli-helpers';

log('Default log');
cmd('yarn lint');
info('Info log');
done('Success log');
warn('Warning log');
error('Error log');
verbose('Verbose log');
event('Event log');

Result of different log methods in terminal

renderHeader

Display header with Georgia11 font and optionally author and/or version.

import { renderHeader } from '@cnamts/cli-helpers';

renderHeader('Package', 'Someone', '1.0.0');

Result of renderHeader function in terminal

Contributing

Feel free to open an issue or a pull request to improve this package! Just make sure to respect the code style by running yarn lint and to update the tests and check the coverage with yarn test.

Keywords

FAQs

Package last updated on 27 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc